]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
automountManager: Explicitly track active operations
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 5 Oct 2018 17:09:28 +0000 (19:09 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Mon, 8 Oct 2018 13:18:53 +0000 (13:18 +0000)
As a mount operation's UI may be reused (for example after mistyping
the password), we only close the operation once the mount has finished
(successfully or with error).

We therefore need to track ongoing operations, which we currently do
by monkey-patching the corresponding volume object. However while the
underlying GVolume object indeed remains the same through-out the
operation, the JS wrapper object isn't referenced anywhere and may
thus be garbage collected, resulting in a stuck dialog.

Fix this issue by tracking active operations explicitly, so that all
involved objects are referenced until the end of the operation.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/565

js/ui/components/automountManager.js

index a6cd8579245bb8a50527bf586bec4096682e10ae..3e2dcd9238b24ff598217fe5620149f34c57596e 100644 (file)
@@ -25,6 +25,7 @@ var AutomountManager = new Lang.Class({
     _init() {
         this._settings = new Gio.Settings({ schema_id: SETTINGS_SCHEMA });
         this._volumeQueue = [];
+        this._activeOperations = new Map();
         this._session = new GnomeSession.SessionManager();
         this._session.connectSignal('InhibitorAdded',
                                     this._InhibitorsChanged.bind(this));
@@ -182,7 +183,7 @@ var AutomountManager = new Lang.Class({
             this._allowAutorun(volume);
 
         let mountOp = operation ? operation.mountOp : null;
-        volume._operation = operation;
+        this._activeOperations.set(volume, operation);
 
         volume.mount(0, mountOp, null,
                      this._onVolumeMounted.bind(this));
@@ -219,7 +220,8 @@ var AutomountManager = new Lang.Class({
     },
 
     _reaskPassword(volume) {
-        let existingDialog = volume._operation ? volume._operation.borrowDialog() : null;
+        let prevOperation = this._activeOperations.get(volume);
+        let existingDialog = prevOperation ? prevOperation.borrowDialog() : null;
         let operation = 
             new ShellMountOperation.ShellMountOperation(volume,
                                                         { existingDialog: existingDialog });
@@ -227,8 +229,11 @@ var AutomountManager = new Lang.Class({
     },
 
     _closeOperation(volume) {
-        if (volume._operation)
-            volume._operation.close();
+        let operation = this._activeOperations.get(volume);
+        if (!operation)
+            return;
+        operation.close();
+        this._activeOperations.delete(volume);
     },
 
     _allowAutorun(volume) {